package com.woniuxy02;


public class Test02 {

    public static void main(String[] args) {
        String s1="aaa";
        String s2="aaa";
        String s3=new String("aaa");
        String s4=new String("aaa");
        //== 比地址
        System.out.println(s1==s2);             //true
        // equals String 重写了，比值
        System.out.println(s1.equals(s2));      //true
        System.out.println(s3==s4);             //false
        System.out.println(s3.equals(s4));      //true
        System.out.println(s1);
        s1="bbb";
        System.out.println(s1);

        Object obj=new Object();
        String str=new String("aaa");
        obj=str;
//        if(obj instanceof String){
//            System.out.println("转换");
//            String s= (String) obj;
//        }
        if(obj instanceof String s){
            System.out.println("转换");
            System.out.println(s);
        }
    }
}
